<?php
/**
 * 工单类，提供与工单相关的各种方法
 * Created by PhpStorm.
 * User: zhuyujun
 * Date: 2017/10/18
 * Time: 14:25
 */

namespace App\Engine;

use Framework\BaseClass\Api\Controller;
use Illuminate\Http\Request;

use Framework\Services\ImageUpload\imageProcess;

class Sn
{
    //生成发货单单号
    public static function createWarehouseSendSn()
    {
        $dayStartTime = strtotime(date('Ymd'));
//        $intradayOrderCount = \App\Eloquent\Ygt\WarehouseSend::withTrashed()->where([['created_at', '>=', $dayStartTime]])->get()->count();
        $intradayOrderCount = \App\Eloquent\Ygt\WarehouseSend::where([['created_at', '>=', $dayStartTime]])->get()->count();

        $snIndex = '';
        $intradayOrderCount++;
        if ($intradayOrderCount < 10) {
            $snIndex = sprintf('0%d', $intradayOrderCount);
        } else {
            $snIndex = $intradayOrderCount;
        }
        $sn = 'FHD' . date('ymd') . $snIndex;

        return $sn;
    }

    //生成应收单单号
    public static function createWarehouseBillMoneySn()
    {
        $dayStartTime = strtotime(date('Ymd'));
        $intradayOrderCount = \App\Eloquent\Ygt\WarehouseBillMoney::withTrashed()->where([['created_at', '>=', $dayStartTime]])->get()->count();

        $snIndex = '';
        $intradayOrderCount++;
        if ($intradayOrderCount < 10) {
            $snIndex = sprintf('0%d', $intradayOrderCount);
        } else {
            $snIndex = $intradayOrderCount;
        }
        $sn = 'YSD' . date('ymd') . $snIndex;

        return $sn;
    }

    //生成半成品流水号
    public static function createProcessProductWaterSn()
    {
        $dayStartTime = strtotime(date('Ymd'));
        $intradayOrderCount = \App\Eloquent\Ygt\ProcessProductWater::withTrashed()->where([['created_at', '>=', $dayStartTime]])->get()->count();

        $snIndex = '';
        $intradayOrderCount++;
        if ($intradayOrderCount < 10) {
            $snIndex = sprintf('0%d', $intradayOrderCount);
        } else {
            $snIndex = $intradayOrderCount;
        }
        $sn = 'BCPLS' . date('ymd') . $snIndex;

        return $sn;
    }

}